<template>
  <div class="policy-page">
    <!-- 顶部横幅 -->
    <div class="policy-banner">
      <div class="banner-content">
        <h1>隐私政策</h1>
        <p>最后更新时间: 2024-03-15</p>
      </div>
      <div class="banner-decoration">
        <div class="decoration-circle"></div>
        <div class="decoration-line"></div>
      </div>
    </div>

    <!-- 主要内容 -->
    <div class="policy-content">
      <div class="content-nav">
        <div class="nav-item" v-for="(section, index) in sections" 
             :key="index"
             :class="{ active: currentSection === index }"
             @click="scrollToSection(index)">
          {{ section.title }}
        </div>
      </div>

      <div class="content-main">
        <div v-for="(section, index) in sections" 
             :key="index" 
             :id="'section-' + index"
             class="content-section">
          <h2>{{ section.title }}</h2>
          <div class="section-content" v-html="section.content"></div>
        </div>
      </div>

      <div class="content-sidebar">
        <div class="quick-actions">
          <button @click="downloadPDF">
            <i class="fas fa-download"></i>
            下载PDF版本
          </button>
          <button @click="printPolicy">
            <i class="fas fa-print"></i>
            打印文档
          </button>
        </div>
        <div class="last-update">
          <i class="fas fa-history"></i>
          上次更新: 2024-03-15
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PrivacyPolicy',
  
  data() {
    return {
      currentSection: 0,
      sections: [
        {
          title: '1. 信息收集',
          content: `
            <h3>1.1 我们收集的信息</h3>
            <p>我们收集以下类型的信息：</p>
            <ul>
              <li>账户信息：用户名、电子邮件地址、密码等基本信息</li>
              <li>API使用数据：调用记录、使用频率、性能数据等</li>
              <li>设备信息：IP地址、浏览器类型、操作系统等</li>
            </ul>

            <h3>1.2 收集方式</h3>
            <p>我们通过以下方式收集信息：</p>
            <ul>
              <li>用户主动提供</li>
              <li>自动收集的技术数据</li>
              <li>第三方服务提供商</li>
            </ul>
          `
        },
        {
          title: '2. 信息使用',
          content: `
            <h3>2.1 使用目的</h3>
            <p>我们收集的信息将用于：</p>
            <ul>
              <li>提供和改进API服务</li>
              <li>个性化用户体验</li>
              <li>安全防护和风险控制</li>
              <li>数据分析和服务优化</li>
            </ul>

            <h3>2.2 数据处理</h3>
            <p>所有数据处理遵循：</p>
            <ul>
              <li>数据最小化原则</li>
              <li>目的限制原则</li>
              <li>安全性原则</li>
            </ul>
          `
        },
        {
          title: '3. 信息共享',
          content: `
            <h3>3.1 信息共享原则</h3>
            <p>我们仅在以下情况下共享用户信息：</p>
            <ul>
              <li>获得用户明确授权</li>
              <li>法律法规要求</li>
              <li>服务提供必要</li>
            </ul>

            <h3>3.2 第三方服务商</h3>
            <p>我们可能与以下类型的第三方服务商合作：</p>
            <ul>
              <li>云服务提供商</li>
              <li>分析服务提供商</li>
              <li>支付服务提供商</li>
            </ul>
          `
        },
        {
          title: '4. 数据安全',
          content: `
            <h3>4.1 安全措施</h3>
            <p>我们采取以下措施保护您的数据：</p>
            <ul>
              <li>数据加密传输与存储</li>
              <li>访问控制和认证</li>
              <li>定期安全审计</li>
              <li>应急响应机制</li>
            </ul>

            <h3>4.2 数据保护</h3>
            <p>我们承诺：</p>
            <ul>
              <li>遵守数据保护法规</li>
              <li>实施严格的数据访问控制</li>
              <li>定期更新安全措施</li>
            </ul>
          `
        },
        {
          title: '5. 用户权利',
          content: `
            <h3>5.1 您的权利</h3>
            <p>作为用户，您拥有以下权利：</p>
            <ul>
              <li>访问您的个人数据</li>
              <li>更正不准确的数据</li>
              <li>删除个人数据</li>
              <li>限制数据处理</li>
              <li>数据可携带性</li>
            </ul>

            <h3>5.2 行使权利</h3>
            <p>您可以通过以下方式行使权利：</p>
            <ul>
              <li>账户设置页面</li>
              <li>联系客服支持</li>
              <li>发送邮件请求</li>
            </ul>
          `
        }
      ]
    }
  },

  methods: {
    scrollToSection(index) {
      this.currentSection = index;
      const element = document.getElementById(`section-${index}`);
      if (element) {
        element.scrollIntoView({ behavior: 'smooth' });
      }
    },

    downloadPDF() {
      // 实现PDF下载逻辑
      console.log('Downloading PDF...');
    },

    printPolicy() {
      window.print();
    }
  },

  mounted() {
    document.title = 'E特尔诺-隐私政策';
    
    // 监听滚动以更新当前章节
    const observer = new IntersectionObserver((entries) => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          const sectionId = entry.target.id;
          this.currentSection = parseInt(sectionId.split('-')[1]);
        }
      });
    }, { threshold: 0.5 });

    // 等待DOM更新后再添加观察者
    this.$nextTick(() => {
      this.sections.forEach((_, index) => {
        const element = document.getElementById(`section-${index}`);
        if (element) {
          observer.observe(element);
        }
      });
    });
  },

  beforeDestroy() {
    // 清理观察者
    if (this.observer) {
      this.observer.disconnect();
    }
  }
}
</script>

<style scoped>
/* 在最前面添加这些全局重置样式 */
ul, li {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.policy-page {
  min-height: 100vh;
  background: #f8f9fa;
}

/* 顶部横幅样式 */
.policy-banner {
  background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
  color: white;
  padding: 4rem 2rem;
  position: relative;
  overflow: hidden;
}

.banner-content {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.banner-content h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.banner-decoration {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
}

.decoration-circle {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  top: -150px;
  right: -150px;
}

.decoration-line {
  position: absolute;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(-45deg);
  top: 50%;
}

/* 主要内容样式 */
.policy-content {
  max-width: 1200px;
  margin: -50px auto 0;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 250px 1fr 250px;
  gap: 2rem;
  position: relative;
}

/* 导航栏样式 */
.content-nav {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  position: sticky;
  top: 2rem;
  height: fit-content;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-item {
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-item:hover {
  background: rgba(26, 35, 126, 0.05);
  color: #1a237e;
}

.nav-item.active {
  background: #1a237e;
  color: white;
}

/* 主要内容区域样式 */
.content-main {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.content-section {
  margin-bottom: 3rem;
}

.content-section h2 {
  font-size: 2rem;
  background: linear-gradient(135deg, #1a237e, #0d47a1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e3f2fd;
}

.content-section h3 {
  font-size: 1.5rem;
  color: #1a237e;
  margin: 2rem 0 1rem;
  position: relative;
  padding-left: 1rem;
}

.content-section h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, #1a237e, #0d47a1);
  border-radius: 2px;
}

.section-content {
  color: #333;
  line-height: 1.6;
}

.section-content ul {
  margin: 1rem 0;
  padding-left: 0;
  list-style: none;
}

.section-content li {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  position: relative;
  line-height: 1.6;
}

.section-content li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 6px;
  height: 6px;
  background: #1a237e;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.2);
  transition: all 0.3s ease;
}

.section-content li:hover {
  transform: translateX(5px);
  background: rgba(26, 35, 126, 0.05);
  border-radius: 4px;
  padding: 0.5rem 1rem 0.5rem 2rem;
}

.section-content li:hover::before {
  background: #0d47a1;
  transform: scale(1.2);
}

/* 侧边栏样式 */
.content-sidebar {
  position: sticky;
  top: 2rem;
  height: fit-content;
}

.quick-actions {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-actions button {
  width: 100%;
  padding: 0.75rem;
  margin: 0.5rem 0;
  border: none;
  border-radius: 8px;
  background: #1a237e;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.quick-actions button:hover {
  background: #0d47a1;
  transform: translateY(-2px);
}

.last-update {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 响应式调整 */
@media (max-width: 1200px) {
  .policy-content {
    grid-template-columns: 200px 1fr;
  }
  
  .content-sidebar {
    display: none;
  }
}

@media (max-width: 768px) {
  .policy-content {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  
  .content-nav {
    display: none;
  }
  
  .banner-content h1 {
    font-size: 2rem;
  }
}
</style> 